# -*- coding = utf-8 -*-
# @Time: 2023-10-28 15:54
# @Author: DavidXie03
# @File: forms.py
# @Software: PyCharm

from django import forms
from .models import *

class CanteenForm(forms.ModelForm):
    class Meta:
        model = Canteen
        fields = ("id", "name", "address", "telNum", "adm_id") # 验证所有字段
        widgets = {
            'id': forms.TextInput(attrs={'id': 'id', 'class':'form-control'}),
            'adm_id': forms.TextInput(attrs={'id': 'uid', 'class': 'form-control'}),
            'name': forms.TextInput(attrs={'id': 'name_id', 'class': 'form-control'}),
            'address': forms.TextInput(attrs={'id': 'name_id', 'class': 'form-control'}),
            'telNum': forms.TextInput(attrs={'id': 'telNum_id', 'class': 'form-control'}),
        }

        labels = {
            "id": "ID",
            'adm_id': "管理员ID",
            "name": "名字",
            "address": "地址",
            "telNum": "电话",
        }

class StoreForm(forms.ModelForm):
    class Meta:
        model = storeInfo
        fields = "__all__" # 验证所有字段
        widgets = {
            'id': forms.TextInput(attrs={'id': 'uid', 'class': 'form-control'}),
            'sel_id': forms.TextInput(attrs={'id': 'sel_id', 'class': 'form-control'}),
            'can_id': forms.TextInput(attrs={'id': 'can_id', 'class': 'form-control'}),
            'name': forms.TextInput(attrs={'id': 'name_id', 'class': 'form-control'}),
            'reletiveAddress': forms.TextInput(attrs={'id': 'reletiveAddress_id', 'class': 'form-control'}),
            'telNum': forms.TextInput(attrs={'id': 'telNum_id', 'class': 'form-control'}),
        }

        labels = {
            "id": "ID",
            "sel_id": "商家ID",
            "can_id": "饭堂ID",
            "name": "名字",
            "reletiveAddress": "地址",
            "telNum": "电话"
        }

class FoodForm(forms.ModelForm):
    class Meta:
        model = food
        fields = '__all__' # 验证所有字段
        widgets = {
            'id': forms.TextInput(attrs={'id': 'id_id', 'class':'form-control'}),
            'sto_id': forms.TextInput(attrs={'id': 'sto_id_id', 'class': 'form-control'}),
            'name': forms.TextInput(attrs={'id': 'name_id', 'class': 'form-control'}),
            'price': forms.TextInput(attrs={'id': 'price_id', 'class': 'form-control'}),
        }

        labels = {
            "id": "ID",
            "sto_id": "商铺ID",
            "name": "名字",
            "price": "单价",
        }

class OrderCreateForm(forms.ModelForm):
    class Meta:
        model = order
        fields = ("state", )
        widgets = {
            # 'id': forms.TextInput(attrs={'id': 'id_id', 'class':'form-control'}),
            # 'nor_id': forms.PasswordInput(attrs={'id': 'nor_id_id', 'class': 'form-control'}),
            # 'orderTime': forms.TextInput(attrs={'id': 'orderTime_id', 'class': 'form-control'}),
            # 'totalPrice': forms.SelectMultiple(attrs={'id': 'userType_id', 'class': 'form-control'}),
            # 'state': forms.Select(attrs={'id': 'telNum_id', 'class': 'form-control'}),
        }

        labels = {
            "id": "订单ID",
            "nor_id": "客户ID",
            "orderTime": "订餐时间",
            "totalPrice": "总价格",
            "state": "订单状态",
        }

class OrderUpdateForm(forms.ModelForm):
    class Meta:
        model = order
        fields = ("state", )
        widgets = {
            # 'id': forms.TextInput(attrs={'id': 'id_id', 'class':'form-control'}),
            # 'nor_id': forms.PasswordInput(attrs={'id': 'nor_id_id', 'class': 'form-control'}),
            # 'orderTime': forms.TextInput(attrs={'id': 'orderTime_id', 'class': 'form-control'}),
            # 'totalPrice': forms.SelectMultiple(attrs={'id': 'userType_id', 'class': 'form-control'}),
            'state': forms.Select(attrs={'id': 'telNum_id', 'class': 'form-control'}),
        }

        labels = {
            "id": "订单ID",
            "nor_id": "客户ID",
            "orderTime": "订餐时间",
            "totalPrice": "总价格",
            "state": "订单状态",
        }

class UserInfoForm(forms.ModelForm):
    class Meta:
        model = UserInfo
        fields = '__all__' # 验证所有字段
        widgets = {
            'account': forms.TextInput(attrs={'id': 'account_id', 'class':'form-control'}),
            'password': forms.PasswordInput(attrs={'id': 'password_id', 'class': 'form-control'}),
            'userName': forms.TextInput(attrs={'id': 'userName_id', 'class': 'form-control'}),
            'userType': forms.SelectMultiple(attrs={'id': 'userType_id', 'class': 'form-control'}),
            'telNum': forms.TextInput(attrs={'id': 'telNum_id', 'class': 'form-control'}),
        }

        labels = {
            "account": "账号",
            "password": "密码",
            "userName": "用户名",
            "userType": "用户类型",
            "telNum": "电话",
        }

class UserLoginForm(forms.ModelForm):
    class Meta:
        model = UserInfo
        fields = ('account', "password")
        widgets = {
            'account': forms.TextInput(attrs={'id': 'account_id', 'class':'form-control'}),
            'password': forms.PasswordInput(attrs={'id': 'password_id', 'class': 'form-control'}),
        }

        labels = {
            "account": "账号",
            "password": "密码",
        }

class UserRegisterForm(forms.ModelForm):
    class Meta:
        model = UserInfo
        fields = '__all__' # 验证所有字段
        widgets = {
            'account': forms.TextInput(attrs={'id': 'account_id', 'class': 'form-control'}),
            'userName': forms.TextInput(attrs={'id': 'userName_id', 'class': 'form-control'}),
            'password': forms.PasswordInput(attrs={'id': 'password_id', 'class': 'form-control'}),
            'userType': forms.Select(attrs={'id': 'userType_id', 'class': 'form-select'}),
            'telNum': forms.NumberInput(attrs={'id': 'telNum_id', 'class': 'form-control'}),
        }

        labels = {
            "account": "账号",
            "userName": "用户名",
            "password": "密码",
            "userType": "用户类型",
            "telNum": "电话",
        }

class AdministratorForm(forms.ModelForm):
    class Meta:
        model = Administrator
        fields = '__all__' # 验证所有字段
        widgets = {
            'id': forms.TextInput(attrs={'id': 'uid', 'class': 'form-control'}),
            'account': forms.TextInput(attrs={'id': 'account_id', 'class': 'form-control'}),
            'realName': forms.TextInput(attrs={'id': 'realName_id', 'class': 'form-control'}),
        }

        labels = {
            "id": "学工号",
            "account": "账号",
            "realName": "真实姓名"
        }

class SellerForm(forms.ModelForm):
    class Meta:
        model = Seller
        fields = '__all__'  # 验证所有字段
        widgets = {
            'id': forms.TextInput(attrs={'id': 'uid', 'class': 'form-control'}),
            'account': forms.TextInput(attrs={'id': 'account_id', 'class': 'form-control'}),
            'realName': forms.TextInput(attrs={'id': 'realName_id', 'class': 'form-control'}),
        }

        labels = {
            "id": "学工号",
            "account": "账号",
            "realName": "真实姓名"
        }

class NormalUserForm(forms.ModelForm):
    class Meta:
        model = NormalUser
        fields = '__all__' # 验证所有字段
        widgets = {
            'id': forms.TextInput(attrs={'id': 'uid', 'class': 'form-control'}),
            'account': forms.TextInput(attrs={'id': 'account_id', 'class': 'form-control'}),
            'realName': forms.TextInput(attrs={'id': 'realName_id', 'class': 'form-control'}),
            'deliveryAddress': forms.TextInput(attrs={'id': 'deliveryAddress_id', 'class': 'form-control'}),
        }

        labels = {
            "id": "学工号",
            "account": "账号",
            "realName": "真实姓名",
            "deliveryAddress": "外卖地址",
        }

class NormalUserUpdateForm(forms.ModelForm):
    class Meta:
        model = NormalUser
        fields = ('deliveryAddress', ) # 验证所有字段
        widgets = {
            # 'id': forms.TextInput(attrs={'id': 'uid', 'class': 'form-control'}),
            # 'account': forms.TextInput(attrs={'id': 'account_id', 'class': 'form-control'}),
            # 'realName': forms.TextInput(attrs={'id': 'realName_id', 'class': 'form-control'}),
            'deliveryAddress': forms.TextInput(attrs={'id': 'deliveryAddress_id', 'class': 'form-control'}),
        }

        labels = {
            # "id": "学工号",
            # "account": "账号",
            # "realName": "真实姓名",
            "deliveryAddress": "外卖地址",
        }